package com.dc.business.datacollectbusiness.mapper;

import com.dc.business.datacollectbusiness.model.brandModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

@Mapper
public interface brandStateMapper {

    // 查询每个厂家前天、昨天的数据
    @SelectProvider(type = BrandSqlProvider.class, method = "getAllBrandStateList")
    List<brandModel> preTwoDayBrandStateList(@Param("formName") String formName, @Param("startTime") String startTime, @Param("endTime") String endTime);


    class BrandSqlProvider {
        public String getAllBrandStateList(@Param("formName") String formName, @Param("startTime") String startTime, @Param("endTime") String endTime) {
            return new SQL() {{
                SELECT("DISTINCT name, dataCode, dataValue, statDate, uploadDate");
                FROM(formName);
                WHERE("statDate BETWEEN #{startTime} AND #{endTime}");
            }}.toString();
        }
    }

}
